package org.restoran.service.impl;

import org.restoran.model.User;
import org.restoran.repository.UserRepository;
import org.restoran.service.CrudService;
import org.restoran.service.UserService;
import org.restoran.service.parser.Parser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.io.Writer;
import java.util.Collection;
import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 * User: ekaterina
 * Date: 11/15/13
 * Time: 10:17 AM
 * To change this template use File | Settings | File Templates.
 */
@Repository
@Service
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public class UserServiceImpl implements UserService {

    private final UserRepository userRepository;

    private final Parser parser;

    @Autowired
    public UserServiceImpl(UserRepository userRepository, Parser parser) {
        this.userRepository = userRepository;
        this.parser = parser;
    }

    @Override
    public User findOne(Integer id) {
        return userRepository.findOne(id);
    }

    @Override
    public Iterable<User> findAll() {
        return userRepository.findAll();
    }

    @Override
    public User save(User user) {
        Objects.requireNonNull(user, "Entity " + user.getClass() + "must not be null");
        return userRepository.save(user);
    }

    @Override
    public void delete(User deleted) {
        userRepository.delete(deleted);
    }

    @Override
    public void delete(Integer deletedId) {
        userRepository.delete(deletedId);
    }

    @Override
    public String parseToJson(User entity) {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void parseToJson(Writer writer, User entity) {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public String parseToJson(Collection<User> objects) {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void parseToJson(Writer writer, Collection<User> args) {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public User parseFromJson(String json, Class<User> type) {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }
}